/**
 * Created by admin on 2017/4/20.
 */
(function () {
    var tool = {};
    tool.httpsUrl = "http://192.168.1.24:9999";


    tool.ajax = function (key, headera, data, success) {
        $.ajax({
            url: key,
            data: data,
            dataType: 'json',
            type: 'POST',
            jsonpCallback: "successCallback",
			jsonp: "callback",
            async: true,
            headers: headera,
            success: success,
            error:function (e) {
                console.log(e);
            }

        });
    };
    tool.header={
        public_key:'040CD66A84025B94CEAC3EC1B49C92D0',
        app_key:'ZQXQ-JSD',
        source:'1',
        client_id:'IMEI',
        channel:'tencent',
        app_version:'1.0.1',
        timestamp:'',
        signature:''
    };
    tool.getparamsStr=function(dataContact) {
        var c;
        var a = [];
        $.each(dataContact, function(key, val) {
            a[a.length] = key;
        });
        a.sort();
        $.each(a, function(i, key) {
            c += encodeURI("&"+key+"="+dataContact[key]) ;
            //c += "&"+key+"="+dataContact[key];
        });
        paramsStr = c.split("undefined&")[1];
        return paramsStr;
    }
    /*---------------------字段名排序（紧急联系人）--------------------------*/
    tool.getencodeURIComponent=function(dataContact) {
        var c;
        var a = [];
        $.each(dataContact, function(key, val) {
            a[a.length] = key;
        });
        a.sort();
        $.each(a, function(i, key) {
            c += encodeURI("&"+key+"="+dataContact[key]) ;
            //c += "&"+key+"="+dataContact[key];
        });
        paramsStr = c.split("undefined&")[1];
        var reg=/,/g;
        var regs=/:/g;
        paramsStr=paramsStr.replace(reg,'%2C');
        paramsStr=paramsStr.replace(regs,'%3A');
        return paramsStr;
    }
    window.tool = tool;

})();